package com.zs.members.controller;

import com.gsj.common.pojo.R;
import com.zs.members.pojo.entity.Client;
import com.zs.members.pojo.vo.ClientVo;
import com.zs.members.service.IClientService;
import com.zs.members.service.impl.ClientServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clms-nine
 * @description: 客户的控制层
 * @author: 张硕
 * @create: 2021-07-23 21:26
 **/
@RestController
@Api(tags = "会员信息控制")
@RequestMapping("members/client")
public class ClientController {
    @Autowired
    private IClientService clientService;

    @ApiOperation(value = "条件查询并分页")
    @PostMapping("/get/{currentPage}/{pageSize}")
    public R get(@PathVariable Integer currentPage, @PathVariable Integer pageSize,@RequestBody ClientVo clientVo){
        return clientService.get(currentPage,pageSize,clientVo);
    }

    @ApiOperation(value = "添加或修改的方法")
    @PostMapping("/saveOrUpdate")
    public R saveOrUpdate(@RequestBody Client client){
//        System.out.println("++++++++++++++++++++++++"+client);
        clientService.saveOrUpdate(client);
        return R.ok();
    }

    @ApiOperation(value = "删除的方法")
    @DeleteMapping("/delectById/{id}")
    public R delectById(@PathVariable Integer id){
        clientService.removeById(id);
        return R.ok();
    }

}
